package com.example.park_management.controller;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.example.park_management.entity.Constructioninspections_kzx;
import com.example.park_management.service.IConstructioninspectionsService_kzx;
import org.springframework.web.bind.annotation.*;
import javax.annotation.Resource;
import java.util.List;

import org.springframework.web.bind.annotation.RestController;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author 泽西
 * @since 2023-12-06
 */
@RestController
@RequestMapping("/constructioninspections")
public class ConstructioninspectionsController_kzx {


        @Resource
        private IConstructioninspectionsService_kzx constructioninspectionsService;
//新增或更新
@PostMapping
public Boolean save(@RequestBody Constructioninspections_kzx constructioninspectionsKzx) {
        return constructioninspectionsService.saveConstructioninspections(constructioninspectionsKzx);
        }

        @DeleteMapping("/{ProjectID}")
        public Boolean delete(@PathVariable Integer projectID) {
                return constructioninspectionsService.removeById(projectID);
                }
        @GetMapping
        public List<Constructioninspections_kzx> findAll() {
                return constructioninspectionsService.list();
        }
        @GetMapping("/{ProjectID}")
        public Constructioninspections_kzx findOne(@PathVariable Integer projectID) {
                return constructioninspectionsService.getById(projectID);
                }
        @GetMapping("/page")
        public Page <Constructioninspections_kzx> findPage(@RequestParam Integer pageNum,
                                                           @RequestParam Integer pageSize,
                                                           @RequestParam(defaultValue = "") String projectName,
                                                           @RequestParam(defaultValue = "") String ConstructionLocation) {
                QueryWrapper<Constructioninspections_kzx> queryWrapper = new QueryWrapper<>();
        if(!"".equals(projectName)){
        queryWrapper.like("ProjectName",projectName);
        }
        queryWrapper.orderByDesc("projectID");
                queryWrapper.orderByDesc("projectID");
                return constructioninspectionsService.page(new Page<>(pageNum, pageSize),queryWrapper);
                }

}

